{% extends 'visites/include/base.html' %}
<!--Page-->
    <!--Reight Content-->
{% block content %}
            <div class="page-content-wrapper">
                <div class="container-fluid">
                    <div class="table-outside">
                        <table class="table" id="tab">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>微信号</th>
                                <th>注册日期</th>
                                <th>所在社区</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for user in posts %}
                            <tr>
                                <!--<td scope="row"><span class="numberClass"></span></td>-->
                                <td scope="row">{{forloop.counter | add:page_start}}</td>
                                <td id = "wechat_number">{{ user.wechat_number }}</td>
                                <td>{{ user.registration_date|date:"Y-m-d H:i:s" }}</td>
                                <td id="cname" style="max-width: 500px">{% for address in user.addresses %}{{ address.c_name }}{% if forloop.revcounter != 1 %}、{% endif %}{% endfor %}</td>
                                <td><a class="btn btn-info none-radius" href="/order/orderuser?id={{ user.id }}" >历史订单</a> </td>
                            </tr>
                            {% endfor %}
                           </tbody>
                        </table>
                    </div>
                    <div class="row order-page">
                        <nav aria-label="Page navigation example">
                            <ul class="pagination">
                                {% if posts.has_previous %}
                                <li class="page-item">
                                    <a class="page-link" href="?page={{ posts.previous_page_number }}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                        <span class="sr-only">Previous</span>
                                    </a>
                                </li>
                                {% endif %}
                                {% for pg in posts.paginator.page_range %}
                                    {% if posts.number == pg %}
                                        <li class="active "><a class="page-link" href="?page={{ pg }}">{{ pg }}</a></li>
                                    {% else %}
                                        {% if pg == '...' %}
                                            <li><span class="page-link">{{ pg }}</span></li>
                                        {% else %}
                                            <li><a class="page-link" href="?page={{ pg }}">{{ pg }}</a></li>
                                        {% endif %}
                                    {% endif %}
                                {% endfor %}
                                {% if posts.has_next %}
                                <li>
                                    <a class="page-link" href="?page={{ posts.next_page_number }}" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                        <span class="sr-only">Next</span>
                                    </a>
                                </li>
                                {% endif %}
                            </ul>
                        </nav>
                    </div>
                </div>
            </div>
<script src="/static/visites/js/jquery.min.js"></script>
<script>
{#序号从1开始#}
{#$(function(){#}
{#        function number(){#}
{#        for(var i=0;i< $(".numberClass").length;i++){#}
{#        $(".numberClass").get(i).innerHTML = i+1;#}
{#        }#}
{#        }#}
{#        number();#}
{# });#}
$(document).ready(function () {
    //取表格第三列的所有数据
    cnames = $("table tr").find("td:eq(3)");
    for(var s =0;s<cnames.length;s++){
        var cname = cnames[s].innerHTML;
        carr = cname.split("、");
        var newcarr = [];//存放去重数据
        var a = {};//临时列表存储数据
            for(var i= 0; i< carr.length;i++){
                if( !a[ carr[i] ]){
                    a[ carr[i]] = true;
                    newcarr.push(carr[i])
                }
            }
        //存放newcarr数组的拆分结果
        var dd = '';
        for(var j= 0; j< newcarr.length;j++){
            dd = dd + '、'+newcarr[j]
        }
        //从dd的第一个字符开始
        dd = dd.substring(1);
        //截取的新的字符串赋值给cname
        cnames[s].innerHTML = dd;
    }
});
</script>
{% endblock %}
